package GroupName.Project_1;

public class Configuration {
	
	private String currentWorkDir;			//Java环境工作目录
	private String encodeCfgFileAbsPath;	//编码配置文件绝对路径
	private String decodeCfgFileAbsPath;	//解码配置文件绝对路径
	private String secertFileAbsPath;		//秘密文件绝对路径
	private String extractFileAbsPath;		//提取文件绝对路径
	private String execEnvAbsPath;			//exe运行时的环境绝对路径
	private String encodeExeAbsPath;		//编码exe所在路径
	private String decodeExeAbsPath;		//解码exe所在路径
	
	public Configuration(String currentWorkDir, String exeDirName, String secertFileAbsPath, String extractFileAbsPath){
		this.currentWorkDir = currentWorkDir;
		this.execEnvAbsPath = currentWorkDir+"/exe/"+exeDirName+"/env";
		this.encodeExeAbsPath = currentWorkDir+"/exe/"+exeDirName+"/lencod.exe";
		this.decodeExeAbsPath = currentWorkDir+"/exe/"+exeDirName+"/ldecod.exe";
		this.encodeCfgFileAbsPath = execEnvAbsPath+"/cfg/encoder_baseline.cfg";
		this.decodeCfgFileAbsPath = execEnvAbsPath+"/cfg/decoder.cfg";
		this.secertFileAbsPath = secertFileAbsPath;
		this.extractFileAbsPath = extractFileAbsPath;
	}
	
	public void setExtractFileAbsPath(String extractFileAbsPath){
		this.extractFileAbsPath = extractFileAbsPath;
	}
	
	public void setSecertFileAbsPath(String secertFileAbsPaths){
		this.secertFileAbsPath = secertFileAbsPaths;
	}
	
	public String getCurrentWorkDir() {
		return currentWorkDir;
	}

	public String getEncodeCfgFileAbsPath() {
		return encodeCfgFileAbsPath;
	}

	public String getDecodeCfgFileAbsPath() {
		return decodeCfgFileAbsPath;
	}

	public String getSecertFileAbsPath() {
		return secertFileAbsPath;
	}

	public String getExtractFileAbsPath() {
		return extractFileAbsPath;
	}
	
	public String getExecEnvAbsPath(){
		return execEnvAbsPath;
	}
	
	public String getEncodeExeAbsPath(){
		return encodeExeAbsPath;
	}
	
	public String getDecodeExeAbsPath(){
		return decodeExeAbsPath;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Java环境工作目录 : "+currentWorkDir+"\n");
		sb.append("exe运行时的环境绝对路径 : "+execEnvAbsPath+"\n");
		sb.append("编码exe的绝对路径 : "+encodeExeAbsPath+"\n");
		sb.append("解码exe的绝对路径 : "+decodeExeAbsPath+"\n");
		sb.append("编码cfg的绝对路径 : "+encodeCfgFileAbsPath+"\n");
		sb.append("解码cfg的绝对路径 : "+decodeCfgFileAbsPath+"\n");
		sb.append("秘密文件绝对路径 : "+secertFileAbsPath+"\n");
		sb.append("提取文件绝对路径 : "+extractFileAbsPath);
		return sb.toString();
	}

	public static class Builder{
		private String currentWorkDir;		//Java环境工作目录
		private String exeDirName;			//可执行文件所在的目录名
		private String secertFileAbsPath;	//秘密文件绝对路径
		private String extractFileAbsPath;	//提取文件绝对路径
		
		public Builder setExeDirName(String exeDirName) {
			this.exeDirName = exeDirName;
			return this;
		}

		public Builder setCurrentWorkDir(String currentWorkDir) {
			this.currentWorkDir = currentWorkDir;
			return this;
		}

		public Builder setSecertFileAbsPath(String secertFileAbsPath) {
			this.secertFileAbsPath = secertFileAbsPath;
			return this;
		}

		public Builder setExtractFileAbsPath(String extractFileAbsPath) {
			this.extractFileAbsPath = extractFileAbsPath;
			return this;
		}

		public Configuration build(){
			return new Configuration(currentWorkDir, exeDirName, secertFileAbsPath, extractFileAbsPath);
		}
	}
}
